package david.java.flink.datasources;

import org.apache.flink.streaming.api.functions.source.SourceFunction;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Description:
 * @Author: Zhaodawei
 * @Date: Create in 上午10:21 2020/12/14
 */
public class SocketDatasource implements SourceFunction<String> {
    private volatile boolean isRunning = true;
    ServerSocket serverSocket ;



    public SocketDatasource() throws IOException {
        serverSocket = new ServerSocket(7777);
    }


    @Override
    public void run(SourceContext ctx) throws Exception {

        Socket socket = serverSocket.accept();
        // socket.
    }

    @Override
    public void cancel() {
        isRunning = false;
    }
}
